<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

class CreateGradesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('grades', function (Blueprint $table) {
            $table->id();
            $table->integer('store_id')->default(0)->comment('店铺id');
            $table->tinyInteger('level')->default(0)->comment('会员等级: 从0开始');
            $table->string('title', 60)->default('')->comment('等级名称');
            $table->string('describe', 60)->default('')->comment('等级描述');
            $table->string('icon', 80)->default('')->comment('等级图标');
            $table->tinyInteger('type')->default(0)->comment('卡牌背景类型 1 图片 / 2 渐变色 获取不到类型 或 类型不合法 则使用配置文件中的统一默认渐变色');
            $table->string('bc_img', 255)->default('')->comment('卡片背景颜色');
            $table->string('color_first', 60)->default('')->comment('渐变色1');
            $table->string('color_second', 60)->default('')->comment('渐变色2');
            $table->integer('jf_num')->unsigned()->default(0)->comment('等级购买要求(单位 元) 对应为用户零售总价');
            $table->string('recommend')->default('')->comment('等级推荐要求(JSON),等级推荐要求(JSON) {"grade":1,"num":1} 为空或获取不到, 默认无推荐要求');
            $table->timestamps();
        });

        DB::statement("ALTER TABLE `grades` comment '店铺会员级别表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('grades');
    }
}
